<template>
    <el-dialog title="表格设置" 
        :visible.sync="getDialogStatus.stTableSettings">

        <div v-if="getTables.length>0">
            <el-collapse v-model="activeNames" @change="handleChange">
                <el-collapse-item title="常规设置" name="1">
                    <el-checkbox v-model="settings.contextMenu">右键菜单</el-checkbox>
                    <el-checkbox v-model="settings.autoWrapRow">自动填充</el-checkbox>
                    <el-checkbox v-model="settings.rowHeaders">列的头部</el-checkbox>
                    <el-checkbox v-model="settings.colHeaders">行的头部</el-checkbox>
                    <el-checkbox v-model="settings.comments">备注</el-checkbox>
                    <el-checkbox v-model="settings.mergeCells">合并</el-checkbox>
                    <el-checkbox v-model="settings.formulas">公式支持</el-checkbox>
                </el-collapse-item>
                {{tempTransfer}}
            </el-collapse>
        </div>

    </el-dialog>
</template>

<script>

import {mapMutations,mapGetters} from 'vuex';
export default {
    props:{
        
    },
    data() {
        return {
            activeNames:'',
            settings:{},
        };
    },
    computed:{
        ...mapGetters(['getDialogStatus',
            'getCurrentActiveTable',
            'getTables',
            'getCurrentActiveTable']),
        tempTransfer(){
            if(this.getTables.length>0 && this.getCurrentActiveTable){
                //console.log(this.getCurrentActiveTable);
                setTimeout(()=>{
                    this.settings=this.getCurrentActiveTable.table.settings;
                },200);
            }
        }
    },
    watch:{
        settings:{
            handler(newVal,oldVal){
                this.getCurrentActiveTable.hs.updateSettings(newVal);
                this.updateSettings({
                    index:this.getCurrentActiveTable.index,
                    data:newVal
                })
            },
            deep:true
        },
        
    },
    mounted(){
        
    },
    methods:{
         ...mapMutations(['updateSettings']),
        handleChange(){

        },
        updateTableSettingList(){
            if(this.getCurrentActiveTable){
                console.log(this.getCurrentActiveTable);
            }
        
        }
    }
}
</script>

<style>
</style>
